﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using SIA.HwAccess;
using SIA.Allarms;

namespace SIA.AutomationControl
{
    public partial class AllarmsIcon : UserControl
    {
        IHwSignals _signals = new HwSignals();



        IAllarmsCollections _allarmsCollection = new GenericAllarmsCollecions();

        public IAllarmsCollections AllarmsCollection { get { return _allarmsCollection; } set { _allarmsCollection = value; } }

        public AllarmsIcon()
        {
            InitializeComponent();
            this.Visible = false;

            _allarmsCollection.RiseONAllarm += new AllarmEvent(_allarmsCollection_RiseONAllarm);
            _allarmsCollection.RiseOFFAllarm += new AllarmEvent(_allarmsCollection_RiseOFFAllarm);
        }

        void _allarmsCollection_RiseOFFAllarm(IAllarm allarm)
        {
            foreach (IAllarm a in _allarmsCollection)
                if (a.isActive) return;

            this.Visible = false;
        }

        void _allarmsCollection_RiseONAllarm(IAllarm allarm)
        {
            this.Visible = true;
        }
    }
}
